<html>
   <head>
      <title>Historical data statistics</title>
   </head>
   <body>
      <table>
         <tr>
            <g:form>
            <td>
                    <g:select name="select1" from="${['DIA', 'SPY', 'GLD']}" value="${params.select1}"/>
            </td> 
            <td>
               <g:select name="fieldVar" from="${['Open', 'High', 'Low', 'Close']}" value="${params.fieldVar}"/>
            </td>
            <td>
               <g:actionSubmit name="doStats" action="index" value="Submit"/>
            </td>
            </g:form></td>
         </tr>
      </table>
      
      <g:if test="${chiSquare != null}">
                <p>Basic statistics for ${params.select1} (${params.fieldVar})</p>
                <table border="1">
                    <tr>
                        <td>Min</td>
                        <td>Max</td>
                        <td>Mean</td>
                        <td>Standard Deviation</td>
                        <td>Skewness</td>
                        <td>Kurtosis</td>
                    </tr>
                    
                    <tr>
                        <td>${statsMap["min"]}</td>
                        <td>${statsMap["max"]}</td>
                        <td>${statsMap["mean"]}</td>
                        <td>${statsMap["stddev"]}</td>
                        <td>${statsMap["skewness"]}</td>
                        <td>${statsMap["kurtosis"]}</td>
                    </tr>
                </table>
                
                <p>Entropy</p>
                
                <table border="1">
                    <tr>
                        <td>Observed</td>
                        <td>Natural</td>
                        <td>Levy c=1</td>
                    </tr>
                    <tr>
                        <td>${sampleEntropy}</td>
                        <td>${naturalEntropy}</td>
                        <td>${levyEntropy}</td>
                    </tr>
                </table>
                
                <p>Chi tests</p>
                
                <table border="1">
                    <tr>
                        <td>Reject at</td>
                        <td>Chi square</td>
                        <g:each in="${1..9}">  
                            <td>${100 - it} %</td>
                        </g:each> 
                    </tr>
                    <tr>
                        <td>Gauss</td>
                        <td>${chiSquare}</td>
                        <g:each in="${0..8}">  
                            <td>${rejections[it]}</td>
                        </g:each> 
                    </tr>
                    
                    <tr>
                        <td>Levy c=1</td>
                        <td>${levyChi2}</td>
                        <g:each in="${0..8}">  
                            <td>${levyRejections[it]}</td>
                        </g:each> 
                 </table>
                 
                 <p>Polynomial fits</p> 
                 
                 <table border="1">
                    <tr>
                        <td>Degree</td>
                        <td>Coefficients</td>
                        <td>R square</td>
                    </tr>
                    <tr>
                        <g:each in="${0..5}">  
                        <tr>
                            <td>${it + 1}</td>
                            <td>${fits[it]["coefficients"].toString()}</td>
                            <td>${fits[it]["rsquare"].toString()}</td>
                        </tr>
                        </g:each>
                    </tr>
                 </table>
                 
                 <p>Market efficiency</p>
                 <table border="1">   
                    <tr>
                        <td>Lo MacKinlay ratio</td>
                        <td>Wald Wolfowitz test Z</td>
                    </tr>
                    <tr>
                        <td>${lomac}</td>
                        <td>${waldWolf}</td>
                    </tr>
                </table>
        </g:if>
        
        <br/> <br/>
    </body>
</html>